$(function () {
    if(local.getData("loginInfo")){
        AjaxRequest({
            url:_url+"/money/login/login",
            load:true,
            data:{
                username:local.getData("loginInfo").username,
                password:local.getData("loginInfo").password
            },
            type:"post",
            success(res){
                //var loginInfo={username:("#username").val().trim(),password:$("#upwd").val().trim()}
                //_user.setUserInfo(loginInfo)
                if(isReqSucceed(res)){
                    _user.setUserInfo(res);
                    $(window).attr("location","../index/index.html")
                    return;
                }
            }
        });
    }
    $("#register").click(function () {
            $.actions({
                actions:[
                //     {
                //     text:"手机注册",
                //     onClick:function() {
                //         $(window).attr("location","./phoneRegister/phoneRegister.html")
                //     }
                // },
                    {
                    text:"邮箱注册",
                    onClick:function () {
                        $(window).attr("location","./emailRegister/emailRegister.html")
                    }
                }]
            })
        }
    )
    $("#forgetPassword").click(function(){
        $(window).attr("location","./backPassword/backPassword.html")
    })
    $("#login").click(function () {
        var islogin=true;
        if(!$("#username").val().trim()){
            $.toast("用户名不能为空","text")
            islogin=false;
            return;
        }
        if(!$("#upwd").val().trim()){
            $.toast("密码不能为空","text")
            islogin=false;
            return;
        }
        if(islogin){
            AjaxRequest({
                url:_url+"/money/login/login",
                load:true,
                data:{
                    username:$("#username").val().trim(),
                    password:$("#upwd").val().trim()
                },
                type:"post",
                success(res){
                    var loginInfo={username:$("#username").val().trim(),password:$("#upwd").val().trim()}
                    local.saveData("loginInfo",loginInfo);
                    if(isReqSucceed(res)){
                        _user.setUserInfo(res);
                        $(window).attr("location","../index/index.html")
                    }
                }
            });
        }

    })
})